import request from '@/utils/request'

export function getTheses(uid, year) {
  return request({
    url: `/teachers/${uid}/theses`,
    method: 'get',
    params: {
      year
    }
  })
}

export function getThesisById(id) {
  return request({
    url: `/theses/${id}`,
    method: 'get'
  })
}

export function putTheses(thesis, id) {
  return request({
    url: `/theses/${id}`,
    method: 'put',
    params: thesis
  })
}

export function postTheses(thesis) {
  return request({
    url: `/theses`,
    method: 'post',
    params: thesis
  })
}

export function choseStudent(id, uid) {
  return request({
    url: `/theses/${id}/students/${uid}`,
    method: 'post'
  })
}

export function deleteTheses(id) {
  return request({
    url: `/theses/${id}`,
    method: 'DELETE'
  })
}

export function getChosenTheses(uid, year, chosen) {
  return request({
    url: `/students/${uid}/theses`,
    method: 'get',
    params: {
      year,
      chosen
    }
  })
}

export function getUnChosenTheses(uid, year, page, limit) {
  return request({
    url: `/students/${uid}/theses`,
    method: 'get',
    params: {
      year,
      chosen: false,
      page,
      limit
    }
  })
}

export function postChosenTheses(uid, id) {
  return request({
    url: `/students/${uid}/theses/${id}`,
    method: 'post'
  })
}

export function deleteChosenTheses(uid, id) {
  return request({
    url: `/students/${uid}/theses/${id}`,
    method: 'delete'
  })
}

export function getThesesById(id) {
  return request({
    url: `/teachers/theses/${id}`,
    method: 'get'
  })
}
